<?php $this->_extends('_layouts/main_layout'); ?>

<?php $this->_block('title'); ?>
More Spin - LaLaLoot
<?php $this->_endblock(); ?>

<?php $this->_block('keywords');?>
<meta name="keywords" content="<?php echo $site['keywords']; ?>" />
<?php $this->_endblock();?>

<?php $this->_block('description');?>
<meta name="description" content="LaLaLoot: support our advertisers and sign-up for offers to play our games for free!" />
<?php $this->_endblock();?>

<?php $this->_block('content'); ?>
<div class="mt">
	<?php $this->_element('social'); ?>
</div>
<div class="mm getmorecredits">
	<div class="topad">
		<?php echo str_replace('[[USER_ID]]', $user['id'], $site['ad_top']);?>
	</div>
	<div class="clear" style="height: 10px"></div>
	<div class="left white" style="width: 100%;">
		<div class="title" style="font-size: 25px;">Welcome to Daily Deals</div>
		<div class="tips1">
			<div class="left how">
				<a target="_blank" id="offer_link_url" href="<?php echo url('default/dailydealsclick', array('dailydealsid' => (isset($dailyDealsOffers[0]))? $dailyDealsOffers[0]['id'] : '')); ?>"><img id="offer_picture_url" src="<?php echo (isset($dailyDealsOffers[0]))? $dailyDealsOffers[0]['picture1_url'] : ''; ?>" width="300" height="250" class="left" /></a>
				<div class="clear"></div>
				<div class="left" style="padding: 10px 5px; font-weight: normal; font-size: 16px;">
					<p id="offer_describe_text">
						<?php echo (isset($dailyDealsOffers[0]))? $dailyDealsOffers[0]['describe_text'] : ''; ?>
					</p>
				</div>
			</div>
			<div class="right" style="text-align: center; width: 300px;">
				<div class="title" style="font-weight: normal; font-size: 28px; border-bottom: solid 1px #5CB6F2; padding: 10px 0;">
					<span id="offer_title_text"><?php echo (isset($dailyDealsOffers[0]))? $dailyDealsOffers[0]['title_text'] : ''; ?></span>
					<div class="clear"></div>
				</div>
				<div style="border-top: solid 1px #7EE0FB; border-bottom: solid 1px #5CB6F2; padding: 10px 0;">
					<a id="offer_link_url" target="_blank" href="<?php echo url('default/dailydealsclick', array('dailydealsid' => (isset($dailyDealsOffers[0]))? $dailyDealsOffers[0]['id'] : '')); ?>"><img src="<?php echo $img_url . 'buynow.png'; ?>" /></a>
					<div class="clear"></div>
				</div>
				<div style="border-top: solid 1px #7EE0FB; border-bottom: solid 1px #5CB6F2; padding: 10px 0;">
					<span class="left" style="font-weight:normal; font-size: 13px; line-height: 30px; padding-left: 16px;">TIME REMAINING</span>
					<span id="offer_time_remaining" class="right title" style="line-height: 30px;">
						<?php echo (isset($dailyDealsOffers[0]))? strftime('%H:%M:%S', strtotime($dailyDealsOffers[0]['end_date']) - time()) : ''; ?>
					</span>
					<script type="text/javascript">
						var t;
						function countDown(){
							var time = $('#offer_time_remaining').html().split(':');
							var hour = time[0];
							var min = time[1];
							var sec = time[2];
							if(--sec < 0){
								sec = 59;
								if(--min < 0){
									min = 59;
									if(--hour < 0){
										hour = 0;
										min = 0;
										sec = 0;
									}
								}
							}
							if(hour < 10){
								hour = '0' + hour*1;
							}
							if(min < 10){
								min = '0' + min*1;
							}
							if(sec < 10){
								sec = '0' + sec*1;
							}
							$('#offer_time_remaining').html(hour+':'+min+':'+sec);
							clearTimeout(t);
							t = setTimeout(function(){countDown();}, 1000);
						}
						t = setTimeout(function(){countDown();}, 1000);
						
					</script>
					<div class="clear"></div>
				</div>
				<div style="border-top: solid 1px #7EE0FB; padding: 10px 0; font-weight: normal;">
					<!-- share  
					<a href="<?php echo url('user/step2'); ?>" target="_blank"><img src="<?php echo $img_url . 'sf.png'; ?>" /></a>
					<a href="<?php echo url('user/step3'); ?>" target="_blank"><img src="<?php echo $img_url . 'st.png'; ?>" /></a> -->
				</div>
			</div>
			<div class="clear"></div>
		</div>
		
		
		<?php if(count($dailyDealsOffers) > 1): ?>
			<?php unset($dailyDealsOffers[0]); ?>
			<div class="title" style="font-size: 25px; margin-top: 20px;">More Deals</div>
			<div class="tips1 left" style="cursor: pointer;">
				<div class="left title" id="prebtn" style="width: 30px; text-align: center; color: #191934;">&lt;</div>
				<div class="left" id="pic_wrap" style="width: 650px;">
					<?php foreach($dailyDealsOffers as $k => $dailyDealsOffer): ?>
						<a target="_blank" href="<?php echo url('default/dailydealsclick', array('dailydealsid' => $dailyDealsOffer['id'])); ?>"><img class="dailyDealsOffer" id="<?php echo $dailyDealsOffer['id']; ?>" src="<?php echo $dailyDealsOffer['picture2_url']; ?>" width="120" height="90" style="margin-right:10px;" /></a>    
					<?php endforeach; ?>
					<script>
	//					$('.dailyDealsOffer').click(function(){
	//						var id = $(this).attr('id');
	//						$.ajax({
	//							type: 'GET',
	//							url: '<?php echo url('offer/getDailyDealsOffer'); ?>',
	//							data: {id: id},
	//							success: function(dailyDealsOffer){
	//								$('#offer_picture_url').attr('src', dailyDealsOffer['picture_url']);
	//								$('#offer_describe_text').html(dailyDealsOffer['describe_text']);
	//								$('#offer_title_text').html(dailyDealsOffer['title_text']);
	//								$('#offer_link_url').attr('href', dailyDealsOffer['link_url']);
	//								$('#offer_time_remaining').html(dailyDealsOffer['timeRemaining']);
	//							},
	//							dataType: 'json'
	//						});
	//					});
					</script>
				</div>
				<div class="left title" id="nextbtn" style="width: 30px; text-align: center; color: #191934;">&gt;</div>
				<script src="<?php echo $js_url . 'scrollPic.js' ?>"></script>
				<script>
					$('#pic_wrap').picToggle({
						speed: 20,						//pic cutover speed
						prebtn: $('#prebtn'),			//the obj of prebtn
						nextbtn: $('#nextbtn')			//the obj of next btn
					});
				</script>
			</div>
		<?php endif; ?>
	</div>
	<div class="right rightad">
	</div>
	<div class="clear" style="height: 20px;"></div>
	<div class="bottomad">
		<?php echo $site['ad_bottom']; ?>
	</div>
</div>
<div class="mb"></div>
<?php $this->_endblock(); ?>